﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMSModel;

public partial class Advertise_delete : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string advertiseId = Request["advertiseId"];
            if (!string.IsNullOrEmpty(advertiseId))
            {
                try
                {
                    CMSModel.CMSEntities cms = DAL.DBManager.GetCmsEmtity();
                    CMSModel.Advertise advertise = cms.Advertise.First(x => x.AdvertiseId == advertiseId);
                    cms.DeleteObject(advertise);
                    cms.SaveChanges();
                    ClientScript.RegisterStartupScript(GetType(), "aa", "alert('删除成功');document.location='default.aspx'", true);
                }
                catch (Exception ex)
                {
                    ClientScript.RegisterStartupScript(GetType(), "aa", "alert('删除失败');document.location='default.aspx'", true);
                }
            }
        }
    }
}